package org.kassa.dao;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Properties;
import java.util.logging.Level;
import org.kassa.service.Logger;

public final class DaoHelperImpl {
	
	private static Properties props = new Properties();
	
	public static PreparedStatement getPreparedStatement(String sql) {
            try {
            props.load(new FileReader("jdbc.properties"));

            } catch (FileNotFoundException e) {
                Logger.log("File jdbc.properties not found");
            } catch (IOException e) {
                Logger.log("IOException caught");
                e.printStackTrace();
            }
            
            try {
                return DriverManager.getConnection(props.getProperty("url"),
                    props.getProperty("username"), props.getProperty("password")).prepareStatement(sql);
            } catch (SQLException e) {
                Logger.log("SQLException caught");
                e.printStackTrace();
            }
            return null;
            
        }
            
}
